package main

import (
	"log"

	"golang.org/x/net/context"
	"google.golang.org/grpc"
	 "git.oschina.net/YPTArch/apigateway/grpc/pb"
	"encoding/json"
)

const (
	address     = "192.168.1.183:8082"
)

func main() {
	// Set up a connection to the server.
	conn, err := grpc.Dial(address, grpc.WithInsecure())
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
	c := pb.NewGreeterClient(conn)

	obj := make(map[string]string)

	obj["tt"]="Hi"
	obj["qq"]="test"

	data,err := json.Marshal(obj)
	if err != nil {
		log.Fatalf("could not greet: %v", err)
		return
	}

	r, err := c.Login(context.Background(), &pb.InData{Data: string(data)})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	log.Printf("Data : %s", r.Data)
}